<?php
/**
 * Created by PhpStorm.
 * User: wc
 * Date: 14-7-22
 * Time: 下午2:38
 */

class WX_Controller extends CI_Controller {
    function __construct()
    {
        parent::__construct();

        //加载nusoap
        //保存COOKIE
        $gzh=getGP("gzh")?getGP("gzh"):$_COOKIE["gzh"];
        setcookie("gzh", $gzh, time()+3600*24*360);
        $token=getGP("token")?getGP("token"):$_COOKIE["token"];
        if(!$token){
            $token=$gzh;
        }
        setcookie("token", $token, time()+3600*24*360);
        $openid=getGP("openid")?getGP("openid"):$_COOKIE["openid"];
        setcookie("openid", $openid, time()+3600*24*360);
        $salt=getGP("salt")?getGP("salt"):$_COOKIE["salt"];
        setcookie("salt", $salt, time()+3600*24*360);

    }
}



require_once(FCPATH.'nusoap/lib/nusoap.php');

//封装接口调用
function spInterFace($methodName,$param,$beanName="hdintegralwsservice",$appCode="蓝门"){
    /*
 * 正式接口地址改为：10.254.3.204:6868/CrmService.asmx?WSDL （只能内网登陆）
测试接口地址改为：http://218.90.167.99:8088/CrmService.asmx?WSDL（外网登陆测试）
 */

    //$client = new soapclient("http://218.90.167.99:8088/CrmService.asmx?WSDL",true);
    $client = new soapclient("http://10.254.3.204:8080/CrmService.asmx?WSDL",true);

    $client->soap_defencoding = 'UTF-8';
    $client->decode_utf8 = false;
    $client->xml_encoding = 'UTF-8';
    $params = array(
        'beanName'=>$beanName,
        'methodName'=>$methodName,
        'appCode'=>$appCode,
        'param'=>$param
    );

    $reversed = $client->call('invokeWS',$params);
    $res=json_decode($reversed["invokeWSResult"]);
    return $res;
}